import {Form, Input, message, Modal} from 'antd'
import ProForm, { ProFormText, ProFormDigit } from '@ant-design/pro-form';
import {values} from "lodash";
import {PutNoRefundOrder} from "@/services/ant-design-pro/order";

const NoRefundModal = (props) => {
    const {visible, setVisible, id, orderNumber, noRefund} = props
    const [form] = Form.useForm()
    return (
    <div>
        <Modal
            visible={ visible }
            onCancel={() => {
              setVisible(false)
            }}
            title="不退款原因"
            onOk={() => {
                form.validateFields().then(async values => {
                    noRefund()
                    await PutNoRefundOrder(id,{...values})
                    message.success('不退款原因已完善')
                    setTimeout(()=>{
                      setVisible(false)
                    },1000)
                })
            }}
        >
            <ProForm
                form={form}
                submitter={false}
            >
                <ProFormText  width="md" disabled placeholder={orderNumber} label="不退款单号"/>
                <Form.Item name="refund_reason" label="备注" rules={[{required: true, message: '请输入备注!'}]}>
                  <Input.TextArea showCount={true} placeholder="订单备注" maxLength={200}/>
                </Form.Item>
            </ProForm>
        </Modal>

    </div>
  );
};

export default NoRefundModal;
